<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="query">
				<el-form-item>
					<el-input v-model="query.keyword" placeholder="姓名"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getUsers">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="pageInfo.rows" highlight-current-row v-loading="listLoading" style="width: 100%;">
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="name" label="权限名称" width="180" sortable>
			</el-table-column>
			<el-table-column prop="url" label="地址" width="160" sortable>
			</el-table-column>
			<el-table-column prop="sn" label="唯一权限标识" width="300" sortable>
			</el-table-column>
			<el-table-column prop="descs" label="描述" sortable>
			</el-table-column>
			<el-table-column prop="parent.name" label="父权限" min-width="180" sortable>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination
          layout="total, prev, pager, next"
          @current-change="handleCurrentChange"
          :page-size="query.pageSize"
          :total="pageInfo.total"
          :current-page="query.currentPage"
          style="float:right;">
			</el-pagination>
		</el-col>

	</section>
</template>

<script>
	export default {
		data() {
			return {
				filters: {
					name: ''
				},
        listLoading: false,
        pageInfo:{
          total: 0,
          rows: []
        },
        query: {
          currentPage: 1,
          pageSize: 10,
          keyword: ''
        }
			}
		},
		methods: {
			handleCurrentChange(val) {
				this.query.currentPage = val;
				this.getPermissionList();
			},
			//获取用户列表
			getUsers() {

			},
      getPermissionList() {
        this.$http.post("/permission",this.query)
          .then(result => {
            result = result.data;
            if (result.success) {// true 后端返回了数据
              this.pageInfo = result.data;
            } else {// 后端处理失败
              this.$message({message: result.message,type: 'error'});
            }
          })
          .catch(result => {
            this.$message({message: "网络错误："+result,type: 'error'});
          })
      },
		},
		mounted() {
			this.getUsers();
      this.getPermissionList();
		}
	}

</script>

<style scoped>

</style>